package com.bjpowernode.p2p.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.bjpowernode.p2p.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * ClassName:RedisServiceImpl
 * Package:com.bjpowernode.p2p.service.impl
 * Description: 描述信息
 *
 * @date:2021/7/20 13:26
 * @author:动力节点
 */
@Component
@Service(interfaceClass = RedisService.class,version = "1.0-SNAPSHOT",timeout = 15000)
public class RedisServiceImpl implements RedisService {

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @Override
    public void addCodeMessage(String phone, String codeMessage) {
        redisTemplate.opsForValue().set(phone,codeMessage,15, TimeUnit.MINUTES);
    }

    @Override
    public String getCodeMessage(String phone) {
        return (String) redisTemplate.opsForValue().get(phone);
    }
}
